home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Sunday Times: The Month 2003 December
/
The Sunday Times - The Month 2003-12.iso
/
mac
/
The Month DEC 03
/
engine
/
modules
/
fader.swf
/
scripts
/
frame_1
/
DoAction.as
Wrap
Text File
|
2003-11-10
|
5KB
|
196 lines
function init()
{
trace("fader.init() : strPathPrefix=" + strPathPrefix);
strPath = Tardis.ASSETS_FOLDER + "images/" + Tardis.ActiveSection.id + "/";
var i = 0;
while(i < nodeData.childNodes.length)
{
var mc = this.createEmptyMovieClip("mImage_" + i,10 + i);
mc.imagePath = nodeData.childNodes[i].getText();
mc.origDepth = 10 + i;
mc.id = i;
mc.loadImage = function()
{
trace("fader." + this._name + ".loadImage() : " + (this._parent.strPathPrefix + this._parent.strPath + this.imagePath));
this.createEmptyMovieClip("mImage",2);
this.mImage.loadMovie(this._parent.strPathPrefix + this._parent.strPath + this.imagePath);
this.onEnterFrame = function()
{
if(this.mImage._height > 0)
{
this.isImageLoaded = 1;
delete this.onEnterFrame;
this.onImageLoaded();
}
};
};
mc.fadeIn = function()
{
if(!this.isImageLoaded)
{
this.loadImage();
}
this._alpha = 0;
this._visible = 1;
this.swapDepths(100);
this._parent.fading = this;
this.onEnterFrame = function()
{
this._alpha += 2;
if(this._alpha >= 100)
{
this._alpha = 100;
this.swapDepths(this.origDepth);
this.onEnterFrame = null;
this._parent.setCurrentImage(this.id);
this._parent.onFadeComplete();
}
};
};
mc.showNow = function()
{
delete this.onEnterFrame;
if(!this.isImageLoaded)
{
this.loadImage();
}
this._alpha = 100;
this._visible = 1;
this._parent.setCurrentImage(this.id);
};
mc.hideNow = function()
{
delete this.onEnterFrame;
this._alpha = 0;
this._visible = 0;
};
arrImages.push(mc);
i++;
}
fading = paused = 0;
if(arrImages.length > 1 && nodeData.attributes.controls == "true")
{
mImage_0.onImageLoaded = function()
{
var mc = attachMovie("clp_controls","mc_controls",400);
mc._x = mImage_0._width - (mc._width - 12) - 10;
mc._y = mImage_0._height - (mc._height - 11) - 10;
};
}
mImage_0.showNow();
if(arrImages.length > 1)
{
delay();
}
onComplete();
}
trace("fader frame 1");
depth = 0;
var strPathPrefix;
var nmDelay = 4000;
var arrImages = [];
var strPath;
this.onUnload = function()
{
clearInterval(delayIntervalID);
};
onDelayComplete = function()
{
trace("fader.onDelayComplete() " + delayIntervalID);
clearInterval(delayIntervalID);
delayIntervalID = null;
if(paused != 1)
{
nextImage.fadeIn();
}
};
onFadeComplete = function()
{
trace("fader.onFadeComplete()");
prevImage.hideNow();
if(paused != 1)
{
delay();
}
};
delay = function()
{
trace("fader.delay()");
clearInterval(delayIntervalID);
delayIntervalID = setInterval(this,"onDelayComplete",nmDelay);
};
skipPrev = function()
{
if(delayIntervalID != null)
{
clearInterval(delayIntervalID);
delayIntervalID = null;
}
if(fading)
{
currImage.showNow();
nextImage.hideNow();
fading = 0;
}
else
{
currImage.hideNow();
prevImage.showNow();
}
delay();
};
skipNext = function()
{
if(delayIntervalID != null)
{
clearInterval(delayIntervalID);
delayIntervalID = null;
}
if(fading)
{
fading = 0;
}
currImage.hideNow();
nextImage.showNow();
delay();
};
pause = function()
{
trace("fader.pause()");
clearInterval(delayIntervalID);
delayIntervalID = null;
if(paused == 1)
{
paused = 0;
if(!fading)
{
onDelayComplete();
}
}
else
{
paused = 1;
}
};
setCurrentImage = function(id)
{
trace("fader.setCurrentImage(" + id + ")");
this.currImage = this["mImage_" + id];
if(id == 0)
{
this.prevImage = this["mImage_" + (arrImages.length - 1)];
}
else
{
this.prevImage = this["mImage_" + (id - 1)];
}
if(id == arrImages.length - 1)
{
this.nextImage = mImage_0;
}
else
{
this.nextImage = this["mImage_" + (id + 1)];
}
};